package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("userstatus")
@Slf4j
public class UserStatusController {
    @DubboReference
    private UserService userService;

    @GetMapping("findPage")
    //@PreAuthorize("hasAnyAuthority('CHECKITEM_QUERY')")
    public Result findPage(QueryPageBean queryPageBean) {
        log.info("[用户数据查询---分页查询]data: {}", queryPageBean);
        //1.远程rpc调用查询分页数据
        PageResult pageResult = userService.findPage(queryPageBean);
        //2.封装返回数据结果
        return new Result(true, MessageConst.QUERY_CHECKITEM_SUCCESS, pageResult);
    }
}
